package cn.lopr.im.api.utils;

import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException;
import org.json.JSONException;

import java.io.IOException;

//@Controller
public class MessageHelper {


    //发送短信
    public static boolean SMS(String phoneNumber, String[] params) {

        SmsSingleSender ssender = new SmsSingleSender(Integer.parseInt(System.getProperty("sms_appid")), System.getProperty("sms_appkey"));

        try {
            SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumber, 835567
                    , params, "lopr公众号", "", "");
            System.out.println(result);//查看是否出错
        } catch (JSONException | HTTPException | IOException e) {
            e.printStackTrace();
        }
        return true;
    }

    public static void main(String[] args) {
        SMS("18164440185", new String[]{"1234", "11"});
    }
}

